#ifndef QPARSERWIDGET_H
#define QPARSERWIDGET_H

// GUI CLASSES

#include <QWidget>
#include <QTextEdit>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QListWidget>
#include <QComboBox>
#include <QCheckBox>
#include <QSpinBox>
#include <QLineEdit>
#include <QPushButton>
#include <QMessageBox>
#include <QtSvg>
#include <QSvgWidget>
#include <QSvgRenderer>
#include <QListView>
#include <QStatusBar>

#include "qparser.h"

class QParserWidget : public QWidget
{
    Q_OBJECT
public:
    QParserWidget(QWidget *parent = 0);
    QParser *parser;

signals:
    void newSample(QList<variable>);
    void listChanged(QList<variable>);
    void newVariable(variable);
    void removeVariable(int);
    void editVariable(int,variable);

public slots:
    void datafromServer(QByteArray);

private:
    // GUI OBJECTS

    // Variable Configuration
    QComboBox *variabletype;
    QButtonGroup *vartypeGroup;
    QGroupBox *propertiesBox;
    QRadioButton *abcRadio;
    QRadioButton *numRadio;
    QCheckBox *fixed_length_check;
    QCheckBox *byte_match_check;
    QSpinBox *length_spin;
    QLineEdit *byte_array_edit;
    QLabel *var_name_label;
    QLineEdit *var_name_edit;

    QPushButton *save_button;
    QPlainTextEdit *logView;
    QCheckBox *logShow;
    QPalette varlispal;
    QPalette listwidgetpal;
    QPushButton *abcButton;
    QPushButton *numButton;
    QPushButton *delButton;
    QIcon abcIcon;
    QIcon numIcon;
    QIcon delIcon;
    QListWidget *varDisplay;
    QStatusBar *parserStatus;

    QTableWidget *varTable;
    QStringList varnameList;
    int varnumber;

    QFont tableFont;

    // Layout
    QHBoxLayout *vartypeLayout;
    QHBoxLayout *mainLayout;
    QVBoxLayout *setupLayout;
    QHBoxLayout *ctlButtons;
    QHBoxLayout *fixedlengthLayout;
    QVBoxLayout *settingsLayout;
    QHBoxLayout *bytematchLayout;
    QVBoxLayout *variableConfig;
    QGridLayout *fixednmatchedLayout;
    QHBoxLayout *varnameLayout;
    QVBoxLayout *feedbackLayout;

    // Functions
    void init();
    void testparser();

private slots:
    void addBytes();
    void addNumbers();
    void removeItem();
    void displayConfig(int);
    void type_changed(int);
    void fixed_checked(bool);
    void length_changed(int);
    void match_checked(bool);
    void match_changed(QString);
    void name_changed(QString);
    void parser_response(QList<variable>,bool,QString);

protected:
};

#endif // QPARSERWIDGET_H
